<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./promise.js"></script>
</head>
<body>
    <script>
        // 1. 状态改变的时机 1s钟后
        // 2. 指定成功或失败回调的时机 同步立刻
        // 3. 执行成功或失败的回调时机。状态改变后执行
        let p = new Promise((resolve,reject)=>{
            setTimeout(()=>{
                // resolve('ok');
                reject('error')
            },1000);
        })
        console.log(p);
        p.then(value=>{
            console.log('value: ' + value);
        },reason=>{
            console.log('reason: ' + reason);
        })

    </script>
</body>

</html>